package lex.dm.loader;

import java.sql.Connection;

/**
 * Attribute Information:<br>
 * 
 * <pre>
 *  1) ID number
 *  2) Diagnosis (M = malignant, B = benign)
 *  3-32)
 * 
 *  Ten real-valued features are computed for each cell nucleus:
 * 
 *  a) radius (mean of distances from center to points on the perimeter)
 *  b) texture (standard deviation of gray-scale values)
 *  c) perimeter
 *  d) area
 *  e) smoothness (local variation in radius lengths)
 *  f) compactness (perimeter&circ;2 / area - 1.0)
 *  g) concavity (severity of concave portions of the contour)
 *  h) concave points (number of concave portions of the contour)
 *  i) symmetry 
 *  j) fractal dimension (&quot;coastline approximation&quot; - 1)
 * </pre>
 */
public class WDBCLoader extends AbstractDataLoader
{
	private static final int COLUMN_COUNT = 32;
	private final String fields = createFields();

	public WDBCLoader( Connection con, String tableName )
	{
		super( con, tableName );
	}

	public int getColumnCount()
	{
		return COLUMN_COUNT;
	}

	public String getCreateTableSQL()
	{
		return "create table " + this.getTableName() + fields;
	}
	
	
	
	@Override
	protected String process( int index, String value )
	{
		if( 1 == index )
			return '\'' + value + '\'';
		return super.process( index, value );
	}

	private static String createFields()
	{
		StringBuilder buf = new StringBuilder().append( '(' );
		buf.append( "pid int, " );
		buf.append( "diagnosis char(1), " );
		for(int i=3; i<33; i++ )
		{
			buf.append( 'c' ).append( i ).append( " double" );
			if( i < 32 )
				buf.append( ',' );
		}
		buf.append( ')' );
		return buf.toString();
	}
	
	public static void main(String[] args)
	{
		System.out.println( createFields() );
	}
}
